package homework.exp02;

import java.io.*;
import java.util.Scanner;
import java.util.regex.Pattern;

public class A {
    static Scanner cin = null;

    static {
        try {
            cin = new Scanner(new FileInputStream(new File("A.in")));
        } catch (IOException e) {
            cin = new Scanner(System.in);
        }
    }

    final static String IPV4 = "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";

    public static void main(String[] args) {
        while (cin.hasNextLine()) {
            String ip = cin.nextLine().trim();
            if (Pattern.matches(IPV4, ip)) {
                System.out.println("Y");
            } else {
                System.out.println("N");
            }
        }
        if (cin != null) cin.close();
    }


}